<?php
use common\service\StaticService;
use backend\assets\AdminAsset;
use common\service\GlobalUrlService;

StaticService::includeAppJsStatic(GlobalUrlService::buildStaticUrl('/backend/goods/info.js'),AdminAsset::class);

?>
<form class="layui-form">
    <div class="layui-card">
        <div class="layui-card-header">商品详情</div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">商品分类</label>
                <div class="layui-inline">
                    <select class="oneclass" disabled>
                        <option value="0">└请选择主营类目</option>
                        <?php foreach ($onetree as $val):?>
                            <option value="<?=$val['id']?>" <?php if($val['id'] == $goods['one_tree_id']):?> selected="selected" <?php endif;?>><?=$val['tree_name']?></option>
                        <?php endforeach;?>
                    </select>
                </div>
                <div class="layui-inline">
                    <select class="twoclass" disabled>
                        <option value="0">└请选择一级分类</option>
                        <?php foreach ($twotree as $val):?>
                            <option value="<?=$val['id']?>" <?php if($val['id'] == $goods['two_tree_id']):?> selected="selected" <?php endif;?>><?=$val['tree_name']?></option>
                        <?php endforeach;?>
                    </select>
                </div>
                <div class="layui-inline">
                    <select class="twoclass" disabled>
                        <option value="0">└请选择一级分类</option>
                        <?php foreach ($threetree as $val):?>
                            <option value="<?=$val['id']?>" <?php if($val['id'] == $goods['three_tree_id']):?> selected="selected" <?php endif;?>><?=$val['tree_name']?></option>
                        <?php endforeach;?>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品名称</label>
                <div class="layui-inline">
                    <input type="text" class="layui-input" name="goods_name" value="<?= $goods['goods_name']?>" disabled>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">封面图</label>
                <div class="layui-inline">
                    <img class="pic" src="<?php if($goods['list_img']):echo GlobalUrlService::buildCdnUrl($goods['list_img']); else: echo '/img/add-pic.png';endif;?>" alt="封面图">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">规格</label>
                <div class="layui-inline">
                    <table class="layui-table">
                        <colgroup></colgroup>
                        <thead>
                            <tr>
                                <?php foreach ($attrlist['thead'] as $val):?>
                                    <th><?= $val?></th>
                                <?php endforeach;?>
                                <th>原价</th>
                                <th>折扣价</th>
                                <th>单购价</th>
                                <th>库存</th>
                                <th>图片</th>
                            </tr>
                        </thead>
                        <tbody class="tbody">
                            <?php foreach ($attrlist['tbody'] as $key=>$val):?>
                                <tr>
                                    <?php foreach ($val['val'] as $value):?>
                                        <td><?= $value['value']?></td>
                                    <?php endforeach;?>
                                    <td><label class="layui-form-label" style="text-align:center;"><?= $val['original_price']?></label></td>
                                    <td><label class="layui-form-label" style="text-align:center;"><?= $val['discount_price']?></label></td>
                                    <td><label class="layui-form-label" style="text-align:center;"><?= $val['original_price']?></label></td>
                                    <td><label class="layui-form-label" style="text-align:center;"><?= $val['inventory']?></label></td>
                                    <td>
                                        <img src="<?= $val['image']?>">
                                        <input type="hidden" name="attrimgval" value="<?= $val['images']?>" class="attrimgvalue attrList imgindex<?= $key+1?>">
                                    </td>
                                    <input type="hidden" value="<?= $val['attribute_value_id']?>">
                                    <input type="hidden" value="<?= $val['id']?>">
                                </tr>
                            <?php endforeach;?>
                        </tbody>
                    </table>
                </div>
            </div>
            <?php if(count($attr_des) > 0):?>
                <div class="layui-form-item">
                    <label class="layui-form-label">属性描述</label>
                    <div class="layui-inline">
                        <?php foreach ($attr_des as $val):?>
                            <div class="layui-block">
                                <input type="text" class="layui-input layui-input-inline" value="<?= $val['key']?>" name="key" disabled>
                                <input type="text" class="layui-input layui-input-inline" value="<?= $val['val']?>" name="val" disabled>
                            </div>
                        <?php endforeach;?>
                    </div>
                </div>
            <?php endif;?>
            <div class="layui-form-item">
                <label class="layui-form-label">运费</label>
                <div class="layui-inline">
                    <input type="text" class="layui-input" name="freight" value="<?php echo $goods['freight'];?>" disabled>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品描述</label>
                <div class="layui-input-block">
                    <textarea  class="layui-textarea" placeholder="请自行排版" disabled><?php echo $goods['introduction'];?></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">详情图</label>
                <div class="layui-input-block" id="flowpic">
                    <?php if(!empty($goods['banner'])):?>
                        <?php foreach ($goods['banner'] as $ban):?>
                            <img class="pic" src="<?= GlobalUrlService::buildCdnUrl($ban['img_url'])?>" alt="详情图">
                        <?php endforeach ;?>
                    <?php endif?>
                </div>
            </div>
            <div class="layui-form-item">
                <a class="layui-btn layui-btn-primary" onclick="window.history.go(-1);">返回</a>
            </div>
        </div>
    </div>
</form>

<script type="text/html" id="img">
    <img src="" alt="">
</script>

<style>
    .pic{width:170px;height:170px;}
    .layui-disabled,.layui-disabled:hover{color: #000!important;}
</style>




